package net.cocotea.sqltoy.lambda.factory.condition.opt;

import net.cocotea.sqltoy.lambda.factory.condition.base.BaseConditionAction;
import net.cocotea.sqltoy.lambda.func.SFunction;
import net.cocotea.sqltoy.lambda.util.SqlFragmentUtils;

import java.util.Arrays;

public class Between<T> extends BaseConditionAction<T> {
    public Between(SFunction<T, ?> function, Object value) {
        super(function, value);
        valueName();
    }

    private String valuedName1;
    private String valuedName2;

    @Override
    public String fragment() {
        return SqlFragmentUtils.between(filed, Arrays.asList(valuedName1(), valuedName2()));
    }

    public String valuedName1() {
        return valuedName1;
    }

    public String valuedName2() {
        return valuedName2;
    }

    @Override
    public String valueName() {
        String valuedName = super.valueName();
        valuedName1 = valuedName + "_1";
        valuedName2 = valuedName + "_2";
        return valuedName;
    }
}
